<template>
	<div class="box">
		<HomeNotice :noticeSwiperSlides="noticeSwiperSlides"></HomeNotice>
	</div>
</template>

<script>
	import HomeNotice from "./childNotice";
	import { mapGetters } from "vuex";
	import { getPageTree, initDomTree } from "../../utils/getPageTree";
	import axios from "axios";
	export default {
		name: 'hello',
		data() {
			return {
				noticeSwiperSlides: [],
			}
		},
		computed: {
			...mapGetters([
				"getDomTree"
			]),
		},
		components: {
			HomeNotice,
		},
		methods: {
			queryNotice() {
				let config = {
					url: window.api.customer_host + '/bulletinVue/qryBulletinListFromH5',
					method: 'POST',
					data: {
						"isPage": "false",
						"enterpriseCode": window.api.enterpriseCode,
						"storeId": localStorage.getItem('storeCode'),
						"start":1
					}
				}
				axios(config).then((res) => {
					if(res.data.returnCode === 1) {
						let data = res.data.data[0].results;
						this.noticeSwiperSlides = [];
						for(var i = 0; i < data.length; i++) {
							if(data[i].status == 1) {
								var obj = {};
								obj.title = data[i].title;
								obj.rid = data[i].rid;
								obj.imgUrl = data[i].imgUrl;
								this.noticeSwiperSlides.push(obj);
							}
						}
					}
				})
			},
			inite() {
				PSEvent.listen("NoticeUpdate", () => {
					this.queryNotice()
				});
				PSEvent.listen("changeStoreCode", () => {
					this.queryNotice()
				});
			},
			removeListen() {
				PSEvent.remove("changeStoreCode");
				PSEvent.remove("NoticeUpdate");
			},
		},
		created() {

		},
		mounted() {
			this.queryNotice()
			this.inite()
		},
		updated() {
			//页面更新完毕
		},
		beforeDestroy() {
			this.removeListen()
		},
	}
</script>

<style>

</style>